package pl.jtb.ctl.tabory.ui.editors;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.SectionPart;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

import pl.jtb.ctl.tabory.ui.selection.ISelection;
import pl.jtb.ctl.tabory.ui.selection.ISelectionProvider;

public abstract class AbstractDetailSectionPart<T extends ISelection> extends SectionPart implements ISelectionProvider<T> {

    protected T selection;
    protected String sectionName;
    protected Section parentSection;

    public AbstractDetailSectionPart(Composite parent, FormToolkit toolkit, int style, String sectionName) {
        super(parent, toolkit, style);
        this.sectionName = sectionName;
        parentSection = getSection();
        parentSection.setText(sectionName);
        initGui(parentSection, toolkit);
        postInitGui(parentSection, toolkit);
        initActions();
    }

    protected abstract void initGui(Section parentSection, FormToolkit toolkit);

    protected abstract void postInitGui(Section parentSection, FormToolkit toolkit);

    protected abstract void initActions();

    public abstract void setEnabled(boolean isEnabled);

}
